package br.com.locanet.util;

import java.lang.reflect.ParameterizedType;

public class UtilReflection {
	public static Class<?> getGenericClassType(Class<?> clazz, Integer typePosition) {
		try{
			return (Class<?>) ((ParameterizedType) clazz.getGenericSuperclass()).getActualTypeArguments()[typePosition];
		}catch(ClassCastException e){
			e.printStackTrace();
			return null;
		}
	}
	
	public static Class<?> getGenericClassType(Class<?> clazz){
		return getGenericClassType(clazz, 0);
	}
}
